Skip to content

Fix #8681: handle scrutinee of union types #8722

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 17, 2020

Conversation

liufengyun
Copy link
Contributor

Copy link
Member

@smarter smarter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! By the way, while reviewing this I realized that the following doesn't warn either:

class A
class B
class C

object Test {
  def bar(x: A) = x match {
    case x: (B | C) => x // no warning?
    case _ =>
  }
}

But I guess that should be a separate issue.

Comment on lines 241 to 244
if (foundClsSyms.size == 1 && foundClsSyms.head.isPrimitiveValueClass)
constant(expr, Literal(Constant(foundClsSyms.head == testCls)))
else
transformIsInstanceOf(expr, defn.boxedType(testCls.typeRef), flagUnrelated)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would be nicer as a pattern match foundClsSyms match { case List(foundCls) => ... case _ => ... }

@smarter smarter assigned liufengyun and unassigned smarter Apr 17, 2020
@liufengyun liufengyun merged commit 8884ec0 into scala:master Apr 17, 2020
@liufengyun liufengyun deleted the fix-8681 branch April 17, 2020 17:25
@liufengyun liufengyun restored the fix-8681 branch April 24, 2020 09:06
@liufengyun liufengyun deleted the fix-8681 branch April 24, 2020 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants